import java.util.Calendar;
import java.util.GregorianCalendar;
import java.io.*;
import static java.lang.System.out;

/**
 * Created by 2gua on 2014/9/27.
 * DayOfWeek4Birthday：看看你查询的具体日子是星期几，
 *           比如，查询谁谁的“生日对应是星期几”。
 */

public class Week {
    private String[] date; //保存输入数据：年数、几月、几号。

    //计算输入的日期数据对应的星期几。
    private void caculateData() {
        GregorianCalendar gc = new GregorianCalendar();
        final char[] day_of_week = {'日','一','二','三','四','五','六'};
        int year = gc.get(Calendar.YEAR); //从当前年算起。
        char week;

        for(int i = year; i<= year + Integer.valueOf(date[0]) - 1; i++) {
            gc.set(i, Integer.valueOf(date[1]) - 1, Integer.valueOf(date[2]));

            week = day_of_week[gc.get(Calendar.DAY_OF_WEEK) - 1];

            out.println(i + "年" + date[1] + "月" + date[2] + "号是星期" + week + "。");
        }
    }

    //输入日期数据。
    private void inputData() {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        try {
            out.print("请输入年份范围和日期，格式：往后年数 几月 几号，回车结束：");
            String in = br.readLine();
            date   = in.split(" ");
            out.println("输入结果：" + date[0] + "个年数，" + date[1] + "月" + date[2] + "号。");
        }
        catch(Exception e) {
            out.println("运行出错。");
        } finally {
            try {
                br.close();
                is.close();
            } catch (IOException e) {
                out.println("出错咯。");
            }
        }
    }

    public static void main(String[] args) {
        Week dayOfWeek4Birthday = new Week();

        dayOfWeek4Birthday.inputData();
        dayOfWeek4Birthday.caculateData();
    }
}
